<?php

namespace App\Kuafu\WaiMai\Command;

use App\Kuafu\Config\Model\ConfigModel;
use App\Kuafu\Order\Enum\CodeEnum;
use App\Kuafu\WaiMai\Channel\BaseWaiMai;
use App\Kuafu\WaiMai\Channel\ElmWaiMai;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class WaiMaiRefreshToken extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'waimai:refresh-token';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '外卖-刷新饿了么Token';

    /**
     * Create a new command instance.
     *
     * @return void//
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command
     *
     * @return void
     */

    public function handle()
    {
//        if (config('app.env') != 'prod') {
//            dump('生产环境执行就行了');
//            return;
//        }

        $shopId = (int)ConfigModel::query()->where('key', 'elmApiShop')->value('value');
        if (!$shopId) {
            return;
        }

        dump(ElmWaiMai::getIns(CodeEnum::SOURCE_TYPE_ELM, $shopId)->getToken(ElmWaiMai::FRESH_CHECK_TIME));
    }
}
